import type { ElementHiderRuleConfig } from '../../../types/constants'
import { PageHandler } from '../../../lib/page_handler'
import {
  SO_SEARCH_BASE_SELECTORS,
  SoPageType,
} from '../../../lib/page_handler/platform/so/types'
import {
  ElementSelectorPosition,
  ElementSelectorType,
} from '../../../types/constants'
import { ELEMENT_IDENTIFIER_CONFIG } from '../../service/element_identifier/types'
import { addPrefixToConfig } from '../element_config'

export const SO_INDEX_SEARCH_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#header #bd_tabnav',
    position: ElementSelectorPosition.TopLeft,
    enable: () => {
      const supportPages = [
        SoPageType.IndexSearch,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.weather.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#header #so_weather',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.IndexSearch,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#header #hd_nav',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.IndexSearch,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.aiTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#main #ai_searchbox_tabs',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexSearch,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.oftenSearch.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#main #often_so',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexSearch,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.aiTool.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#main #ai_tools',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexSearch,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.hotList.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#main #card_container',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexSearch,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexSearch,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.backTop.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#goto-top',
    position: ElementSelectorPosition.BottomRight,
    enable: () => {
      const supportPages = [
        SoPageType.IndexSearch,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_INDEX_VIDEO_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .so-nav-container li.so-nav-container__item',
    position: ElementSelectorPosition.TopLeft,
    enable: () => {
      const supportPages = [
        SoPageType.IndexVideo,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .so-nav-container li.so-nav-container__append-right',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.IndexVideo,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexVideo,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_INDEX_WEN_KU_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .so-nav-container ul',
    position: ElementSelectorPosition.TopLeft,
    enable: () => {
      const supportPages = [
        SoPageType.IndexWenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .so-nav-container .top-nav-right',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.IndexWenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.aiTool.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-index__content .wenku-index__search .wenku-index__types',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexWenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.aiCreate.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-index__content .wenku-index__aiCreate',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexWenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.featuredContent.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-index__content .wenku-index__recommend',
    nameZh: '精品推荐',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexWenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.service.documentTools.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-index__content .wenku-index__convert',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexWenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-page__footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexWenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_INDEX_ENCYCLOPEDIA_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#g-hd .so-nav-container',
    position: ElementSelectorPosition.TopLeft,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.headerNav.id]: {
    hide: false,
    selectorType: ElementSelectorType.Class,
    selector: '.new-nav',
    nameZh: '导航栏',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.banner.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#banner-box',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#login-part-tools',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.bannerAd.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#admsg',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.follow.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '.wrap .leftside .left-con > div:has(h2:contains(\'大家在关注\'))',
    nameZh: '大家在关注',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.edit.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.wrap .leftside .left-con .rewardmodbk',
    nameZh: '悬赏编辑',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.todayInHistory.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '.wrap .leftside .left-con > div:has(h2:contains(\'历史上的今天\'))',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.newbieTutorial.id]: {
    hide: false,
    selectorType: ElementSelectorType.Class,
    selector: '.link-box-wrap',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.announcement.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '.wrap .rightside .right-con > div:has(h2:contains(\'百科小喇叭\'))',
    nameZh: '百科小喇叭',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.hotList.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '.wrap .rightside .right-con > div:has(h2:contains(\'百科热搜\'))',
    nameZh: '百科热搜',
    position: ElementSelectorPosition.MiddleRight,
    listen: true,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.rank.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '.wrap .rightside .right-con > div:has(h2:contains(\'百科学霸榜\'))',
    nameZh: '百科学霸榜',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.IndexEncyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_VIDEO_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .nav',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Video,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.unsupportedSearchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#app .nav li:has(a:contains(\'问答\'), a:contains(\'图片\'), a:contains(\'良医\'), a:contains(\'地图\'), a:contains(\'软件\'), a:contains(\'翻译\'))',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Video,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .so-header .so-header__right',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.Video,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.videoAd.id]: {
    hide: false,
    selectorType: ElementSelectorType.Complex,
    selector: '#app .v-list > li:has([data-so-mod=\'list-ad\'])',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Video,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Video,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.backTop.id]: {
    hide: true,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .v-gotop',
    position: ElementSelectorPosition.BottomRight,
    enable: () => {
      const supportPages = [
        SoPageType.Video,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_WEB_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.component.filterComponent.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#header #head .adv-search-wrap',
    nameZh: '时间筛选',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#tabs-wrap #g-hd-tabs',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.unsupportedSearchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: '#tabs-wrap #g-hd-tabs li:has([data-i=ai_wenda], [data-i=image], [data-i=map], [data-i=fanyi])',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTag.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: '#warper #container #main #so_top, #header #head :is(.so-pdr-bd, #head_pdr_guide)',
    nameZh: '搜索标签（固定）',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#header #hd-rtools',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.contentAd.id]: {
    hide: true,
    selectorType: ElementSelectorType.Multiple,
    selector: '#warper #main #m-spread-left, #warper #main .result .m-spread-middle',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.resultAiAnswer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: `#warper #main .result .res-list:has(#mohe-ai_common, #mohe-360shoutiao_AI)`,
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.encyclopedia.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #main .result .res-list:has(#mohe-biu_graph)`,
    nameZh: '结果项-百科',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.everyoneSearching.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#warper #main .result .res-recommend-tag-cover',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.relatedSearches.id]: {
    hide: false,
    selectorType: ElementSelectorType.Complex,
    selector: '#warper #main > .mod-relation',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.searchPagination.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#warper #footer #page',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.rightAside.id]: {
    hide: true,
    selectorType: ElementSelectorType.Mix,
    selector: '#warper #side',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.rightAsideAiAnswer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side #chat_so`,
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.follow.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side .mh-box:has(h3[title=猜您关注])`,
    nameZh: '右侧边栏-猜您关注',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.software.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side .mh-box:has(h3[title=相关软件])`,
    nameZh: '右侧边栏-相关软件',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.work.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side .mh-box:has(h3[title=相关作品])`,
    nameZh: '右侧边栏-相关作品',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.product.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side .mh-box:has(h3[title=相关产品])`,
    nameZh: '右侧边栏-相关产品',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.game.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side .mh-box:has(h3[title=相关游戏])`,
    nameZh: '右侧边栏-相关游戏',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.base.gameWork.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side .mh-box:has(h3[title=游戏作品])`,
    nameZh: '右侧边栏-游戏作品',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.hotList.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side #mohe-hotnews_right`,
    nameZh: '右侧边栏-实时热榜',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.promotion.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side #so_kw-ad`,
    nameZh: '右侧边栏-推广产品',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.guessSearch.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side #lm-rightbottom`,
    nameZh: '右侧边栏-猜你想搜',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.moreResults.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: `#warper #side .mh-all`,
    nameZh: '右侧边栏-更多推荐',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#warper #footer .footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Web,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_NEWS_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#so-nav-container',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.unsupportedSearchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Multiple,
    selector: '#so-nav-container li:has([data-so-c=问答], [data-so-c=图片], [data-so-c=良医], [data-so-c=地图], [data-so-c=软件], [data-so-c=翻译])',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#head .so-header__content .so-header__right',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.tipMessage.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#filter',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.relatedSearches.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#wrapper #main #bd_related',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.searchPagination.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#wrapper #container #page',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.hotSearch.id]: {
    hide: true,
    selectorType: ElementSelectorType.Mix,
    selector: '#wrapper #container .info-stream',
    nameZh: '智能推荐',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.rightAside.id]: {
    hide: true,
    selectorType: ElementSelectorType.Multiple,
    selector: SO_SEARCH_BASE_SELECTORS.rightAside.containerSelector,
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#wrapper #footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.backTop.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#goto-top',
    position: ElementSelectorPosition.BottomRight,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.feedback.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#feedback',
    position: ElementSelectorPosition.BottomRight,
    enable: () => {
      const supportPages = [
        SoPageType.News,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_ENCYCLOPEDIA_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap .so-nav-container',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Encyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.unsupportedSearchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '.page-wrap .so-nav-container li:has(a:contains(\'问答\'), a:contains(\'图片\'), a:contains(\'良医\'), a:contains(\'地图\'), a:contains(\'软件\'), a:contains(\'翻译\'))',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Encyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap .search-at-top__login-part',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.Encyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.tipMessage.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap #container .search-cont .f13',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Encyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.jumpSearch.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap #container .to_haosou',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Encyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.relatedSearches.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap #container .mod-recommend',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Encyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.searchPagination.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap #container #page',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Encyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.rightAside.id]: {
    hide: true,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap #container .aside',
    position: ElementSelectorPosition.MiddleRight,
    enable: () => {
      const supportPages = [
        SoPageType.Encyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap #footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Encyclopedia,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_WEN_KU_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.searchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .so-nav-container',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.unsupportedSearchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '#app .so-nav-container li:has(a:contains(\'问答\'), a:contains(\'图片\'), a:contains(\'良医\'), a:contains(\'地图\'), a:contains(\'软件\'), a:contains(\'翻译\'))',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .so-header__content .so-header__right',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.component.filterComponent.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-search__main .content-filter',
    nameZh: '内容筛选器',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.component.tagFilterComponent.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-search__main .wenku-search__main__tag-filter',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.contentAd.id]: {
    hide: true,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-search__main #fengwu-ads',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.resultAd.id]: {
    hide: true,
    selectorType: ElementSelectorType.Complex,
    selector: '#app .wenku-search__main .wenku-search__resList > li.fengwu-biz',
    nameZh: '结果项-广告',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.relatedSearches.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-search__main .wenku-search__relatedQuery',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.search.searchPagination.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app #so-pagination',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.rightAside.id]: {
    hide: true,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-search__main .wenku-search__main__right',
    position: ElementSelectorPosition.MiddleCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-search__footer-wrap',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.backTop.id]: {
    hide: true,
    selectorType: ElementSelectorType.Mix,
    selector: '#app .wenku-detail__backTop',
    position: ElementSelectorPosition.BottomRight,
    enable: () => {
      const supportPages = [
        SoPageType.Wenku,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_NOT_FOUND_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.search.unsupportedSearchTab.id]: {
    hide: false,
    selectorType: ElementSelectorType.JQuery,
    selector: '.page-wrap #header #g-hd-tabs > li:has(a:contains(\'问答\'), a:contains(\'图片\'), a:contains(\'良医\'), a:contains(\'地图\'), a:contains(\'软件\'), a:contains(\'翻译\'), a:contains(\'音乐\'))',
    position: ElementSelectorPosition.TopCenter,
    enable: () => {
      const supportPages = [
        SoPageType.NotFound,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.userCenter.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap #header .hd-rtools',
    position: ElementSelectorPosition.TopRight,
    enable: () => {
      const supportPages = [
        SoPageType.NotFound,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: '.page-wrap #footer',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.NotFound,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

export const SO_WEN_KU_NOT_FOUND_PAGE_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.default.footer.id]: {
    hide: false,
    selectorType: ElementSelectorType.Id,
    selector: '#ft',
    position: ElementSelectorPosition.BottomCenter,
    enable: () => {
      const supportPages = [
        SoPageType.WenkuNotFound,
      ]
      return supportPages.includes(PageHandler.getCurrentPageType() as SoPageType)
    },
  },
}

/**
 * 所有配置
 */
export const SO_WEB_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  ...addPrefixToConfig(SO_INDEX_SEARCH_PAGE_ELEMENT_CONFIG, 'indexSearch'),
  ...addPrefixToConfig(SO_INDEX_VIDEO_PAGE_ELEMENT_CONFIG, 'indexVideo'),
  ...addPrefixToConfig(SO_INDEX_WEN_KU_PAGE_ELEMENT_CONFIG, 'indexWenku'),
  ...addPrefixToConfig(SO_INDEX_ENCYCLOPEDIA_PAGE_ELEMENT_CONFIG, 'indexEncyclopedia'),
  ...addPrefixToConfig(SO_VIDEO_PAGE_ELEMENT_CONFIG, 'video'),
  ...addPrefixToConfig(SO_WEB_PAGE_ELEMENT_CONFIG, 'web'),
  ...addPrefixToConfig(SO_NEWS_PAGE_ELEMENT_CONFIG, 'news'),
  ...addPrefixToConfig(SO_ENCYCLOPEDIA_PAGE_ELEMENT_CONFIG, 'encyclopedia'),
  ...addPrefixToConfig(SO_WEN_KU_PAGE_ELEMENT_CONFIG, 'wenku'),
  ...addPrefixToConfig(SO_NOT_FOUND_PAGE_ELEMENT_CONFIG, 'notFound'),
  ...addPrefixToConfig(SO_WEN_KU_NOT_FOUND_PAGE_ELEMENT_CONFIG, 'wenkuNotFound'),
}
